
#pragma once

#include "technique.h"
#include "presentTechnique.h"

namespace EggNine {

    enum DeferredPasses {
    GEOMETRY_PASS,
    FINALIZE_GEOMETRY_PASS,
    LIGHT_VOL_PASS,
    LIGHT_RESOLVE_PASS,
    FINALIZE_PASS
};

class DefferedTechnique : public PresentTechnique {
protected:
    GLuint  m_gbufferConstructProgram;
    GLuint  m_lightVolProgram;
    GLuint  m_resolveProgram;

    // diffuse, normal, ds
    GLuint  m_gbuffer[3];
    GLenum  m_drawBuffers[3];
    GLuint  m_resultTex;
    GLuint  m_gbufferFBO;
    GLuint  m_GBuffSampler;

    GLfloat m_nearPlane;
    GLfloat m_farPlane;

    void ResetStateToProgram() const;

public:
    DefferedTechnique(const string& shaderName);
    ~DefferedTechnique();
    void DrawPass(int pass=0) const;
    void SetClipPlanes(GLfloat nearPlane, GLfloat farPlane);
    void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height);
};

} // EggNine
